var _global = require('game/global.js');
var _Scene = require('component/scene.js');
var _inherit = require('core/inherit.js');

/**
 * combin multip scenes as a whole
 * @type {*}
 */
function CombineScene() {
    _Scene.call(this);
    this.mScenes = Array.prototype.slice.call(arguments, 0);
    for (var i = -1, scenes = this.mScenes, l = scenes.length; ++i < l;) {
        _global.unregisterScene(scenes[i]);
        this.addChild(scenes[i]);
    }
}
_inherit(CombineScene, _Scene);
CombineScene.prototype.superOnSizeChange = CombineScene.prototype.onSizeChange = function (w, h) {
    for (var i = -1, scenes = this.mScenes, l = scenes.length; ++i < l;) {
        scenes[i].onSizeChange(w, h);
    }
    this.setSize(w, h);
};
CombineScene.prototype.superUpdate = CombineScene.prototype.update = function (context) {
    for (var i = -1, scenes = this.mScenes, l = scenes.length; ++i < l;) {
        scenes[i].update(context);
    }
};
CombineScene.createCombine = function (init) {
    var clz = _inherit(function () {
        CombineScene.apply(this, arguments);
        init.apply(this, arguments);
    }, CombineScene);
    return clz;
};

module.exports = CombineScene;